package com.example.sys.job.quartz;

import com.example.sys.job.annotation.JobScope;
import org.quartz.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;

@JobScope(name = "测试定时任务", cron = "*/5 * * * * ?", desc = "测试定时任务")
@Service
public class TestJob implements Job {

    Logger logger = LoggerFactory.getLogger(getClass());

    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        logger.debug("当前时间: {}", simpleDateFormat.format(new Date()));
    }
}
